package com.fx.common.impl;

import com.fx.common.ActionControllerHandlerBuilder;
import com.fx.common.MenuItemActionType;
import com.fx.common.MenuItemController;

public class ApplicationControlActionController extends MenuItemController {

    private final MenuItemActionType type;

    private final ActionControllerHandlerBuilder actionControllerHandlerBuilder;

    public ApplicationControlActionController(MenuItemActionType type,
                                              ActionControllerHandlerBuilder actionControllerHandlerBuilder){
        this.type = type;
        this.actionControllerHandlerBuilder = actionControllerHandlerBuilder;
    }

    @Override
    public boolean canPerform() {
        return this.actionControllerHandlerBuilder
                .canPerformControlAction(this.type);
    }

    @Override
    public void perform() {
       this.actionControllerHandlerBuilder.performControlAction(this.type);
    }
}
